#pragma once

#ifndef QBE_INPUT_HANDLES_HPP
#define QBE_INPUT_HANDLES_HPP

#include "./KeyBoardShortcuts.h"

namespace qbe::input {

class HandleBundle : public vsg::Inherit<vsg::Visitor, HandleBundle> {
 public:
  // Mouse相关事件
  void apply(vsg::ButtonPressEvent& e) override;
  void apply(vsg::ButtonReleaseEvent& e) override;

  void apply(vsg::MoveEvent& e) override;

  void apply(vsg::ScrollWheelEvent& e) override;

  // Window相关事件
  void apply(vsg::ConfigureWindowEvent& e) override;

  void apply(vsg::CloseWindowEvent& e) override;

  // Key相关事件
  void apply(vsg::KeyPressEvent& e) override;

  void apply(vsg::KeyReleaseEvent& e) override;

  bool keyPressed(vsg::KeySymbol key_symbol);
  bool keyPressed(const KeyBoardShortcuts& kbs);

  bool keyReleased(vsg::KeySymbol key_symbol);
  bool keyReleased(const KeyBoardShortcuts& kbs);

  bool mouseMoved(int32_t* x, int32_t* y);

  bool mousePressed(vsg::ButtonMask mask);

  bool mouseReleased(vsg::ButtonMask mask);

  bool mouseReleased(uint32_t button);

  bool mouseWheel(int* delta_y);

  bool resized(uint32_t* x, uint32_t* y, uint32_t* width, uint32_t* height);

  void reset();

  void getGlobalKeyEvent(vsg::KeyReleaseEvent& e);

 public:
  bool* enable = nullptr;

  bool mouse_move{false};
  vsg::MoveEvent* move_event{nullptr};

  bool mouse_press{false};
  vsg::ButtonPressEvent* mouse_press_event{nullptr};
  std::vector<vsg::ButtonPressEvent*> mouse_press_events;

  bool mouse_release{false};
  vsg::ButtonReleaseEvent* mouse_release_event{nullptr};
  std::vector<vsg::ButtonReleaseEvent*> mouse_release_events;

  bool mouse_wheel{false};
  vsg::ScrollWheelEvent* mouse_wheel_event{nullptr};

  // 弃用
  bool key_press{false};
  vsg::KeyPressEvent* key_press_event{nullptr};
  // 启用
  std::vector<vsg::KeyPressEvent*> key_press_events;

  // 弃用
  bool key_release{false};
  vsg::KeyReleaseEvent* key_release_event{nullptr};
  // 启用
  std::vector<vsg::KeyReleaseEvent*> key_release_events;

  bool window_resize{false};
  vsg::ConfigureWindowEvent* window_resize_event{nullptr};
  bool window_close{false};
  vsg::CloseWindowEvent* window_close_event{nullptr};
};
}  // namespace qbe::input

#endif